#include "ConfigReader.hpp"
#include <filesystem>
#include <stdexcept>

ConfigReader::ConfigReader()
{
  if(!std::filesystem::exists("dbusConfig.yaml"))
    throw std::runtime_error("DBus服务配置文件不存在");
  config=YAML::LoadFile("dbusConfig.yaml");
  if(!config["camera_id"].IsSequence())
    throw std::runtime_error("配置文件结构错误");
}

std::vector<std::string> ConfigReader::GetCameraID()
{
  std::vector<std::string> list;
  YAML::Node cameraList=config["camera_id"];
  for(int i=0;i<cameraList.size();i++)
    list.push_back(cameraList[i].as<std::string>());
  return list;
}
